package the.one.weather.ui.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import the.one.weather.R;
import the.one.weather.model.WeatherFuture;
import the.one.weather.util.DateUtil;
import the.one.weather.util.WeatherUtil;


//  ┏┓　　　┏┓
//┏┛┻━━━┛┻┓
//┃　　　　　　　┃
//┃　　　━　　　┃
//┃　┳┛　┗┳　┃
//┃　　　　　　　┃
//┃　　　┻　　　┃
//┃　　　　　　　┃
//┗━┓　　　┏━┛
//    ┃　　　┃                  神兽保佑
//    ┃　　　┃                  永无BUG！
//    ┃　　　┗━━━┓
//    ┃　　　　　　　┣┓
//    ┃　　　　　　　┏┛
//    ┗┓┓┏━┳┓┏┛
//      ┃┫┫　┃┫┫
//      ┗┻┛　┗┻┛

/**
 * @author The one
 * @date 2019/5/8 0008
 * @describe TODO
 * @email 625805189@qq.com
 * @remark
 */
public class WeatherFutureAdapter extends BaseQuickAdapter<WeatherFuture, BaseViewHolder> {
  private static final String TAG = "WeatherFutureAdapter";

  private List<String> nextDates;

  public WeatherFutureAdapter() {
    super(R.layout.item_weather_future);
  }

  @Override
  public void setNewData(@Nullable List<WeatherFuture> data) {
    super.setNewData(data);
    nextDates = DateUtil.getNextDateStringList(data.size());
  }

  @Override
  protected void convert(BaseViewHolder helper, WeatherFuture item) {
    int position = helper.getAdapterPosition();
    helper.setText(R.id.tv_week, position == 0 ? "今天" : position == 1 ? "明天" : item.getDate().substring(0, 2));
    helper.setText(R.id.tv_date,nextDates.get(position));
    helper.setText(R.id.tv_temperature,item.getTemperature());
    String weather = WeatherUtil.parseWeather(item.getWeather());
    helper.setText(R.id.tv_weather,weather);
    ImageView ivWeather = helper.getView(R.id.iv_weather);
    ivWeather.setImageResource(WeatherUtil.parseWeatherImage(weather));
  }

}
